package com.zzptc.zzsgz.bdsjws.fragments;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.zzptc.zzsgz.bdsjws.MyApplication;
import com.zzptc.zzsgz.bdsjws.R;
import com.zzptc.zzsgz.bdsjws.adapter.ContactAdapter;
import com.zzptc.zzsgz.bdsjws.fragments.base.BaseFragmentbase;
import com.zzptc.zzsgz.bdsjws.utils.MyUtils;
import com.zzptc.zzsgz.bdsjws.vo.Contact;

import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/6/6.
 */

public class ShowAllContactFragment extends BaseFragmentbase {
    List<Contact> list=null;
    @BindView(R.id.rv_show_contact)
    RecyclerView rvShowContact;
    @Override
    public int getXML() {
        return R.layout.show_all_contact_fragment;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

//        //得到数据
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                list= MyUtils.getAllContacts();
//            }
//        }).start();
        list= MyApplication.getList();
        //写适配器类
        if (list.size()!=0){
        //得到宿主的TextView
        TextView textView= (TextView) getActivity().findViewById(R.id.tv_count);

        ContactAdapter contactAdapter=new ContactAdapter(list,textView);
        //布局管理者
        rvShowContact.setLayoutManager(new LinearLayoutManager(getActivity()));
        rvShowContact.setAdapter(contactAdapter);
        }
    }
}
